package com.bite.demo.controller;

import com.bite.demo.component.UserComponent;
import com.bite.demo.model.UserInfo;
import com.bite.demo.service.UserService;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;



//@RestController
//@ResponseBody
@Controller
public class UserController {

//    属性注入
    @Autowired
    private UserService userService;

//    @Qualifier("u2")
//    @Autowired
    @Resource(name = "userInfo2")
    private UserInfo userInfo;


    //Setter方法注入
//    private UserService userService;
//
//    @Autowired
//    public void setUserService(UserService userService) {
//        this.userService = userService;
//    }

//    private UserService userService;
//    private UserComponent userComponent;
//
//    public UserController() {
//    }
//
//    @Autowired
//    public UserController(UserService userService, UserComponent userComponent) {
//        this.userService = userService;
//    }

    public void sayHi(){

        System.out.println("Hi, UserController...");
        userService.sayHi();
        System.out.println(userInfo);
    }
}
